﻿Imports System.Runtime.CompilerServices

Module Extensions

	<Extension()>
	Function Opacity(col As Color, Alpha As Integer) As Color
		Return Color.FromArgb(Alpha, col)
	End Function

	<Extension()>
	Function Pen(col As Color, Optional Thickness As Integer = 1) As Pen
		Return New Pen(col, Thickness)
	End Function

	<Extension()>
	Function Brush(col As Color) As Brush
		Return New SolidBrush(col)
	End Function

	<Extension()>
	Function Resize(ByVal Image As Image, ByVal x As Integer, ByVal y As Integer, Optional ByVal m As Integer = 0) As Bitmap
		Dim NewImage As New Bitmap(x, y)
		Dim G As Graphics = Graphics.FromImage(NewImage)
		G.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
		G.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
		G.PixelOffsetMode = Drawing2D.PixelOffsetMode.HighQuality
		G.DrawImage(Image, New Rectangle(m, m, x - m * 2, y - m * 2), New Rectangle(0, 0, Image.Width, Image.Height), GraphicsUnit.Pixel)
		Return NewImage
	End Function

	<Extension()>
	Function n2(i As Integer) As String
		Return Format(i, "00")
	End Function

End Module
